/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.bry.database;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.openide.modules.ModuleInstall;
import org.openide.util.Exceptions;

public class Installer extends ModuleInstall {

	@Override
	public void restored() {
		System.setProperty("derby.system.home",
			System.getProperty("netbeans.user",
			System.getProperty("user.home")) + "/databases");
		try {
			Connection connection = DriverManager.getConnection(
				"jdbc:derby:" + System.getProperty("user.home") + "\\db\\MyDBCyberCafe2;create=true","","");
//			PreparedStatement pre =  connection.prepareStatement("CREATE TABLE HOTELAVAILABILITY\n" +
//"     (HOTEL_ID INT NOT NULL, BOOKING_DATE DATE NOT NULL,\n" +
//"	ROOMS_TAKEN INT DEFAULT 0, PRIMARY KEY (HOTEL_ID, BOOKING_DATE))");
			PreparedStatement pre = connection.prepareCall("SELECT * FROM HOTELAVAILABILITY");
			ResultSet result = pre.executeQuery();
			while(result.next()) {
				System.out.println(result.getString("HOTEL_ID"));
			}
			
		
		} catch (SQLException ex) {
			Exceptions.printStackTrace(ex);
		}
		
		System.err.println(System.getProperty("user.home") + "======================================================");
	}

}
